home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / CRobots.lha / CRobots / whirlwind.r < prev   
Text File  |  1990-04-16  |  3KB  |  71 lines

  1. Baumeister GmbH
  2. Markus
  3. /* moves always (never halts) in random directions, so he is difficult to hit
  4.    and fires at others which cross his way
  5. */
  6. main()
  7. {
  8.    long richtung, direc;
  9.    long range, j;
  10.  
  11.    while(1)
  12.    {
  13.        /* are we moving? if not go in random direction */
  14.        if (speed() == 0)
  15.        {
  16.            drive(richtung = rand(360), 30);
  17.            direc = richtung - 25;
  18.        }
  19.        j = 10;     /* only test this ^^ every ten times    */
  20.        while(--j)
  21.        {
  22.            {
  23.            /* are we in the near of a wall, then change direction  */
  24.            long curx, cury;
  25.                if ((curx = loc_x())<170)
  26.                {
  27.                    drive(richtung=rand(110) + 305, 40); /*change direction*/
  28.                    direc = richtung - 25;  /* which direction to look  */
  29.                    drive(richtung, 55);    /* speed up again   */
  30.                }
  31.                else if (curx > 830)
  32.                {
  33.                    drive(richtung = rand(110) + 125, 40);
  34.                    direc = richtung - 25;
  35.                    drive(richtung, 55);
  36.                }
  37.                if((cury = loc_y()) < 160)
  38.                {
  39.                    drive(richtung = rand(100) + 40, 40);
  40.                    direc = richtung - 25;
  41.                    drive(richtung, 55);
  42.                }
  43.                else if (cury > 840)
  44.                {
  45.                    drive(richtung = rand(100) + 220, 40);
  46.                    direc = richtung - 25;
  47.                    drive(richtung, 55);
  48.                }
  49.            }   /* end of local variables   */
  50.            
  51.            if (range = scan(direc, 5))
  52.            {   /* found someone ! */
  53.                if (range < 360)    /* if he's farer, we would probobly miss him */
  54.                    if (range > 70) /* if he's nearer we would also suffer from hit */
  55.                        cannon(direc, range - 21);  /* shoot at him */
  56.                /* scan with higher resolution  */
  57.                if ((range = scan(direc - 3, 1)) > 67)
  58.                    cannon(direc - 3, range - 18);
  59.                if ((range = scan(direc, 1)) > 65)
  60.                    cannon(direc, range - 16);
  61.                if ((range = scan(direc + 3, 1)) > 67)
  62.                    cannon(direc + 3, range - 18);
  63.                if (direc < richtung)
  64.                    direc -= 10;    /* scan whole section again next time */
  65.            }
  66.            else if ((direc += 10) > richtung + 35) /* are we looking in front of us ?*/
  67.                direc = richtung - 35;              /* no => do so! */
  68.        } /* while(--j) */
  69.    } /* while(1) */
  70. } /* main */
  71.